<?php

namespace app\admin\model\fssy;

use think\Model;


class Specialdisease extends Model
{
    // 表名
    protected $name = 'fssy_specialdisease';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'gender_data_text',
        'resident_or_employeed_data_text',
        'remarks_data_text',
        'category_data_text'
    ];

    public function dictsregion()
    {
        return $this->belongsTo('app\admin\model\dicts\Region', 'region_id')->setEagerlyType(0);
    }

    public function dictsdiseaseidname()
    {
        return $this->belongsTo('app\admin\model\dicts\Diseaseidname', 'diseaseidname_id')->setEagerlyType(0);
    }

    public function dictsexpert1()
    {
        return $this->belongsTo('app\admin\model\dicts\Expert', 'expert1_id')->setEagerlyType(0);
    }

    public function dictsexpert2()
    {
        return $this->belongsTo('app\admin\model\dicts\Expert', 'expert2_id')->setEagerlyType(0);
    }



    public function getGenderDataList()
    {
        return ['男' => __('Gender_data 男'), '女' => __('Gender_data 女')];
    }

    public function getResidentOrEmployeedDataList()
    {
        return ['居民' => __('居民'), '职工' => __('职工')];
    }

    public function getRemarksDataList()
    {
        return ['备案' => __('备案'), '未备案' => __('未备案'), '备案时间错' => __('备案时间错')];
    }

    public function getCategoryDataList()
    {
        return ['肿瘤' => __('肿瘤'), '结核' => __('结核')];
    }


    public function getGenderDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender_data']) ? $data['gender_data'] : '');
        $list = $this->getGenderDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getResidentOrEmployeedDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['resident_or_employeed_data']) ? $data['resident_or_employeed_data'] : '');
        $list = $this->getResidentOrEmployeedDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRemarksDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['remarks_data']) ? $data['remarks_data'] : '');
        $list = $this->getRemarksDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCategoryDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['category_data']) ? $data['category_data'] : '');
        $list = $this->getCategoryDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }
}
